//
//  NSString+Base64.m
//  QCash
//
//  Created by 张葱 on 2019/4/23.
//  Copyright © 2019年 Qworks. All rights reserved.
//

#import "NSString+Base64.h"
#import <Security/Security.h>

@implementation NSString (Base64)
- (NSString *) stringPaddedForBase64 {
    NSUInteger paddedLength = self.length + (self.length % 3);
    return [self stringByPaddingToLength:paddedLength withString:@"=" startingAtIndex:0];
}
+(NSString *)identifier
{
    NSString *identifierForVendor = [[UIDevice currentDevice].identifierForVendor UUIDString];
        
    return identifierForVendor;
}

+ (NSString*)getPreferredLanguage
{
        
        NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
        
        NSArray * allLanguages = [defaults objectForKey:@"AppleLanguages"];
        
        NSString * preferredLang = [allLanguages objectAtIndex:0];
        
        NSLog(@"当前语言:%@", preferredLang);
        
        return preferredLang;
        
}

- (NSString *)dealkonggeWithnum:(NSInteger)number
{
    NSString *doneTitle = @"";
    int count = 0;
    for (int i = 0; i < self.length; i++) {
        
        count++;
        doneTitle = [doneTitle stringByAppendingString:[self substringWithRange:NSMakeRange(i, 1)]];
        if (count == number) {
            doneTitle = [NSString stringWithFormat:@"%@ ", doneTitle];
            count = 0;
        }
    }
    NSLog(@"%@", doneTitle);
    return doneTitle;
}

@end
